package com.semanticweb.webapp.model.ontology;

import org.apache.lucene.document.Document;

import com.semanticweb.webapp.ontology.CIDOC;
import com.semanticweb.webapp.ontology.CType;
import com.semanticweb.webapp.ontology.Ont;
import com.semanticweb.webapp.ontology.OntHelper;
import com.semanticweb.webapp.search.IDocument;

/**
 * Class which represents 'Broj maticne dokumentacije' from the chart.
 * 
 * @author Lab
 * 
 */
public class NumberInDocumentation extends DefaultAbstractEntity<Integer> implements IDocument {

    public static final String ONT_IDENTIFIER = "nid";

    public NumberInDocumentation(final String id) {
        super(id);
    }

    @Override
    public void toRDF() {
        if (this.value != null) {
            OntHelper.toRDFValueWithType(this.id, CIDOC.P48, CIDOC.E42, this.value.toString(),
                    Ont.formatURIPart(ONT_IDENTIFIER), CType.NUMBER_IN_DOCUMENTATION);
        }
    }

    public void fromRDF() {
        final String tempValue = OntHelper.fromRDFValueWithType(this.id, CIDOC.P48, CIDOC.E42,
                CType.NUMBER_IN_DOCUMENTATION);
        this.value = (tempValue == null || tempValue.isEmpty()) ? null : Integer.parseInt(tempValue);
    }

    @Override
    public void toIndexDocument(final Document doc) {
        // Nothing to index
    }

}
